package org.csu.jpetstore_users_backend_pj.vo;

import jakarta.validation.constraints.Email;
import jakarta.validation.constraints.NotEmpty;
import lombok.Data;
import org.csu.jpetstore_users_backend_pj.entity.Account;
import org.csu.jpetstore_users_backend_pj.entity.Profile;
import org.csu.jpetstore_users_backend_pj.entity.SignOn;


@Data
public class AccountVO {

    private String username;
    private String password;
    private String pwdHash;
    private String email;
    private String firstName;
    private String lastName;
    private String status;
    private String address1;
    private String address2;
    private String city;
    private String state;
    private String zip;
    private String country;
    private String phone;
    private String giteeId;
    private String giteeAvatar;
    private String giteeNickname;
    private String giteeToken;
    private String favouriteCategoryId;
    private String languagePreference;
    private boolean listOption;
    private boolean bannerOption;
    private String bannerName;

    public void setAccountVO(Account account, Profile profile, String bannerName) {
        this.username = account.getUserid();
        this.email = account.getEmail();
        this.firstName = account.getFirstName();
        this.lastName = account.getLastName();
        this.status = account.getStatus();
        this.address1 = account.getAddress1();
        this.address2 = account.getAddress2();
        this.city = account.getCity();
        this.state = account.getState();
        this.zip = account.getZip();
        this.country = account.getCountry();
        this.phone = account.getPhone();
        this.giteeId=account.getGiteeId();
        this.giteeAvatar=account.getGiteeAvatar();
        this.giteeNickname=account.getGiteeNickname();
        this.giteeToken=account.getGiteeToken();

        this.favouriteCategoryId = profile.getFavouriteCategoryId();
        this.languagePreference = profile.getLanguagePreference();
        this.listOption = profile.isListOption();
        this.bannerOption = profile.isBannerOption();
        this.bannerName = bannerName;
    }

    public Account getAccount() {
        Account account = new Account();
        account.setUserid(username);
        account.setEmail(email);
        account.setFirstName(firstName);
        account.setLastName(lastName);
        account.setStatus(status);
        account.setAddress1(address1);
        account.setAddress2(address2);
        account.setCity(city);
        account.setState(state);
        account.setZip(zip);
        account.setCountry(country);
        account.setPhone(phone);
        account.setGiteeId(giteeId);
        account.setGiteeAvatar(giteeAvatar);
        account.setGiteeNickname(giteeNickname);
        account.setGiteeToken(giteeToken);
        return account;
    }

    public SignOn getSignOn() {
        SignOn signOn = new SignOn();
        signOn.setUsername(username);
        signOn.setPwdHash(pwdHash);
        return signOn;
    }

    public Profile getProfile() {
        Profile profile = new Profile();
        profile.setUserid(username);
        profile.setFavouriteCategoryId(favouriteCategoryId);
        profile.setLanguagePreference(languagePreference);
        profile.setListOption(listOption);
        profile.setBannerOption(bannerOption);
        return profile;
    }
}
